home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Risc World 3
/
Risc World 3.iso
/
SOFTWARE
/
ISSUE6
/
PD
/
PDF
/
GuiLib
/
Task
/
c++
/
GuiGadget
next >
Wrap
Text File
|
2003-02-14
|
5KB
|
132 lines
//--------------------------------------------------------------------------
//
// Copyright (c) 2002, Colin Granville
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following
// conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// * The name Colin Granville may not be used to endorse or promote
// products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//
//--------------------------------------------------------------------------
#include "GuiGadget.h"
#include "swis.h"
GuiToolboxGadget::GuiToolboxGadget(GuiWindow& window, GuiComponentId cid)
: m_window_id(window.id()),m_component_id(cid)
{}
//******************************************************************
void GuiToolboxGadget::fade(bool is_fade)
{
int flags=getFlags();
if (is_fade)
{
if ((flags & GuiToolboxGadget_Faded)==0) setFlags(flags | GuiToolboxGadget_Faded);
}
else
{
if (flags & GuiToolboxGadget_Faded) setFlags(flags &~ GuiToolboxGadget_Faded);
}
}
//******************************************************************
// GuiSlider
//******************************************************************
void GuiSlider::setBounds(int flags,int lower_bound,int upper_bound,int step_size)
{
// lower_bound/upper_bound other way around in book
_swix(Toolbox_ObjectMiscOp,_INR(0,6),
flags,windowId(),578,componentId(),
lower_bound,upper_bound,step_size);
}
//*****************************************************************
//*****************************************************************
//*****************************************************************
void set_component_string(GuiObjectId ob_id,GuiComponentId comp_id,int method_code,const char* str)
{
if (ob_id != NULL_GuiObjectId && comp_id != NULL_GuiComponentId)
_swix(Toolbox_ObjectMiscOp,_INR(0,4),0,ob_id,method_code,comp_id,str);
}
//*****************************************************************
string get_component_string(GuiObjectId id,GuiComponentId cid,int method_code,int item)
{
string s;
if (id != NULL_GuiObjectId && cid != NULL_GuiComponentId)
{
_kernel_swi_regs reg;
reg.r[0]=0;
reg.r[1]=id;
reg.r[2]=method_code;
reg.r[3]=cid;
reg.r[4]=0;
reg.r[5]=0;
reg.r[6]=item;
if (_kernel_swi(Toolbox_ObjectMiscOp,®,®)==NULL)
{
s.resize(reg.r[5]-1);
if (s.size()==reg.r[5]-1)
{
reg.r[4]=(int)s.data();
_kernel_swi(Toolbox_ObjectMiscOp,®,®);
}
}
}
return s;
}
//*****************************************************************
void set_component_value(GuiObjectId ob_id,GuiComponentId comp_id,int method_code,int value)
{
if (ob_id != NULL_GuiObjectId && comp_id != NULL_GuiComponentId)
_swix(Toolbox_ObjectMiscOp,_INR(0,4),0,ob_id,method_code,comp_id,value);
}
//*****************************************************************
int get_component_value(GuiObjectId ob_id,GuiComponentId comp_id,int method_code)
{
int val;
return (ob_id != NULL_GuiObjectId && comp_id != NULL_GuiComponentId &&
_swix(Toolbox_ObjectMiscOp,_INR(0,3) | _OUT(0),0,ob_id,method_code,comp_id,&val)==NULL)?
val:0;
}